package com.hotel.controller;

import com.hotel.pojo.BookOrder;
import com.hotel.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author shkstart  入住订单控制器
 * @create 2021-06-26 19:47
 */
@Controller
public class BookController {

    @Autowired
    BookService bookService;

    //跳转到预订界面
    @RequestMapping("/skip/toBookOrder")
    public String toBookOrder(Model model) {
        List<BookOrder> list = bookService.list(null);
        model.addAttribute("books",list);
        return "admin/views/bookOrder";
    }

    //删除订单
    @RequestMapping("/deletedBook/{id}")
    public String deletedBook(@PathVariable("id")Integer id){
        boolean b = bookService.removeById(id);
        System.out.println("订单删除结果为===>" + b);
        return "redirect:/skip/toBookOrder";
    }
}
